import { baseUrl } from './config';
// import obj from './config';
// console.log(baseUrl);
// console.log(obj.projectName);

import axios from 'axios';


export const ajax = (url,data,succ) => {
    url = baseUrl + url;
    data = data || {};
    axios.get(url,{params: data}).then(res=>{
        if (res.data.status === 0) {
            succ(res.data.data);
        } else {
            alert(res.data.msg);
        }

    }).catch(()=> {
        alert('网络请求失败')
    })
}

const add0 = (num) => {
  return num<10?'0'+num:num;
}

export const formatDate = (time) => {
    let date = new Date();
    let Y = date.getFullYear();
    let M = date.getMonth() + 1;
    let D = date.getDate();
    return `${add0(Y)}年${add0(Y)}月${add0(D)}日`;
}

